<%@ include file="/common/taglibs.jsp"%>
<%@ taglib prefix="content" tagdir="/WEB-INF/tags/content"%>
<title><fmt:message key="customer.login.title" /></title>
<input type="hidden" id="isLoginPage"/><%--用于标识登录页 --%>
<div class="main clearfix">
	<div class="login clearfix">
		<div class="box login_box">
			<content:getAdvertisement positionCode="login">
				<c:choose>
					<c:when test="${not empty advertisements}">
			    		<%@ include file="../advertisement/adView.jsp"%>
					</c:when>
					<c:otherwise>
						<img src="${imagePath}/temp/login520X400.png" width="520" height="400" />
					</c:otherwise>
				</c:choose>
	    	</content:getAdvertisement>		
		</div>
		<div class="go_login">
			<div class="top">
				<b><fmt:message key="login.heading"/></b><span class="en">User Login</span>
			</div>
			<div class="content">
				<form method="post" name="loginForm" id="loginForm"	action="${ctxPath}/j_security_check?continue=${param.continue}" onsubmit="login(this);return false;">
					<table width="94%" border="0" cellspacing="0" cellpadding="0"	class="table_login">
						<c:if test="${param.error != null}">
							<tr><td colspan="2"><div id="errorMsg" class="error_txt"><fmt:message key="customer.login.fail"/></div></td></tr>
						</c:if>
						<tr style="vertical-align:top;">
							<th width="50px"><fmt:message key="label.username"/>：</th>
							<td><input name="j_username" id="j_username" validConf="required" tabindex="1"  type="text" class="inputtxt3"
								style="width: 220px; height: 22px;" />
							</td>
						</tr>
						<tr style="vertical-align:top;">
							<th><fmt:message key="label.password" />：</th>
							<td><input name="j_password" id="j_password" validConf="required"  tabindex="2"  type="password" class="inputtxt3"
								style="width: 220px; height: 22px;" />
							</td>
						</tr>
						<c:if test="${applicationScope.appConfig.isRememberMeEnabled}">
							<tr>
								<th>&nbsp;</th>
								<td class="rememberMe"><input name="rememberMe" id="rememberMe" type="checkbox"	 tabindex="4" value="" />&nbsp;&nbsp;
										<label for="rememberMe"><fmt:message key="login.rememberMe"/></label>
								</td>
							</tr>
						</c:if>	
						<tr>
							<th>&nbsp;</th>
							<td class="do"><input id="loginBtn" name="" tabindex="5" type="image"	src="${txtImagePath}/btn_login.png" alt="<fmt:message key="login.button"/>" />&nbsp;&nbsp;
								<a	href="${ctxPath}/customer/forgetPassword.html"><fmt:message key="customer.login.forgetPassword"/></a>
							</td>
						</tr>
					</table>
				</form>
				<c:if test="${param.fromCheckout eq '1' and appConfig.isAnonymousCheckoutEnabled}">
					<div class="quick_checkout">
						<h3><fmt:message key="login.checkout.anonymous.title"/></h3>
						<p>
							<fmt:message key="login.checkout.anonymous.tip"/><a href="${ctxPath}/checkout.html?type=anonymous"><fmt:message key="login.checkout.anonymous.button"/></a>
						</p>
					</div>
				</c:if>
				<div class="go_register">
					<h3><fmt:message key="login.register.title"/></h3>
					<p>
						<fmt:message key="login.register.tip"/><a href="${ctxPath}/customer/register.html"><fmt:message key="login.register.button"/></a>
					</p>
				</div>
			</div>
		</div>
	</div>
</div>


<c:set var="probizJs_validation" value="true" scope="request"/>
<script type="text/javascript">
$j(document).ready(function () {
	__FMTExtend = {
		login_wait:"<fmt:message key="login.wait" />",
		customer_login_fail:"<fmt:message key="customer.login.fail"/>"
	};
	$j.extend(__FMT, __FMTExtend); 
	
	resetForm();
	applyValidate($('j_username'),"required");
	applyValidate($('j_password'),"required");
	
	<c:if test="${param.error != null}">
  		setTimeout(sysMsgFadeOut4Login,errorMsgTimeout);
    </c:if>
});	


function sysMsgFadeOut4Login(){
	$j('#errorMsg').fadeOut(2000);
}

function login(form){
	if(validateForm($('loginForm'))){
		$j('#loginBtn').after("<i class='loading'>"+__FMT.login_wait+"</i>");
		$j('#loginBtn').remove();
		form.submit();
	}
}


function resetForm(){
	var form=$("loginForm");
	if (getCurrentUserName() != null && getCurrentUserName() != ""){
		form.j_username.value=getCurrentUserName();
		form.j_password.value="";
		form.j_password.focus();
	}else{
		form.j_username.value="";
		form.j_password.value="";
		form.j_username.focus();
	}
}
</script>
